﻿using System;
using System.Collections.Generic;

namespace Milo.Eg.Web
{
    using Domain;

    public class DaoFactory
    {
        public IList<Customer> GetCustomers()
        {
			return new Customer[] { GetCustomerByCode("AAA"), GetCustomerByCode("BBB") };
        }

        public Customer GetCustomerByCode(string code)
        {
            Customer cust = null;

            if (code == "AAA")
            {
                cust = new Customer();
                cust.Code = "AAA";
                cust.Person = new Person();
                cust.DeliveryAddress = new Address("1", "M33 6ER");
                cust.InvoiceAddress = new Address();

                cust.Person.Title = "Mr";
                cust.Person.Forenames = "Initial";
                cust.Person.Surname = "Test";
            }

			if (code == "BBB")
			{
				cust = new Customer();
				cust.Code = "BBB";
				cust.Person = new Person();
				cust.DeliveryAddress = new Address("2","OL8 7QO");
				cust.InvoiceAddress = new Address();

				cust.Person.Title = "Mr";
				cust.Person.Forenames = "Second";
				cust.Person.Surname = "Go";
			}

            if (cust == null)
                throw new Exception("Cannot find customer code " + code);

            return cust;
        }
    }
}
